﻿package mortal.game.view.guild.otherpanel
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guildNew.data.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildIntroducePanel extends GuildOtherBasePanel
    {
        private var _txtGuildName:GTextFiled;
        private var _txtGuildMaster:GTextFiled;
        private var _txtGuildLevel:GTextFiled;
        private var _txtGuildCamp:GTextFiled;
        private var _txtGuildMembersNum:GTextFiled;
        private var _txtGuildBranchLevel:GTextFiled;
        private var _txtGuildPurpose:GTextFiled;
        private var _bgGuildPurpose:ScaleBitmap;
        private var _btnApply:GButton;
        private var _guildData:SMiniGuildInfo;
        private static var _instance:GuildIntroducePanel = null;

        public function GuildIntroducePanel(param1:ILayer = null)
        {
            super(param1);
            setSize(280, 282);
            title = "" + Language.getString(71182);
            return;
        }// end function

        override public function layoutUI() : void
        {
            UIFactory.gTextField(Language.getString(60046) + " : ", 17, 40, 60, 20, this, GlobalStyle.textFormatJiang);
            UIFactory.gTextField(Language.getString(60075) + " : ", 17, 64, 60, 20, this, GlobalStyle.textFormatJiang);
            UIFactory.gTextField(Language.getString(60001) + Language.getString(60027) + " : ", 17, 88, 60, 20, this, GlobalStyle.textFormatJiang);
            UIFactory.gTextField(Language.getString(60073) + " : ", 17, 116, 60, 20, this, GlobalStyle.textFormatJiang);
            UIFactory.gTextField(Language.getString(60023) + " : ", 17, 140, 60, 20, this, GlobalStyle.textFormatJiang);
            UIFactory.gTextField(Language.getString(60006) + " : ", 17, 164, 60, 20, this, GlobalStyle.textFormatJiang);
            this._txtGuildName = UIFactory.gTextField("XXXXXXXXXXXXXX", 75, 40, 120, 20, this, GlobalStyle.textFormatItemGreen);
            var _loc_1:String = "<a href=\'event:masterLink\' target = \'\'><font color=\'#ffffff\'><u>XXXXXXXXX</u></font></a>";
            this._txtGuildMaster = UIFactory.gTextField(_loc_1, 75, 64, 120, 20, this, null, true);
            this._txtGuildLevel = UIFactory.gTextField("24", 75, 88, 60, 20, this, GlobalStyle.textFormatYellow);
            this._txtGuildMembersNum = UIFactory.gTextField("11/50", 75, 116, 60, 20, this, GlobalStyle.textFormatItemWhite);
            this._txtGuildBranchLevel = UIFactory.gTextField("11", 75, 140, 100, 20, this, GlobalStyle.textFormatItemWhite);
            this._bgGuildPurpose = UIFactory.bg(75, 164, 192, 72, this, ImagesConst.InputBg);
            this._txtGuildPurpose = UIFactory.gTextField("", 76, 164, 190, 72, this, GlobalStyle.textFormatItemWhite);
            this._txtGuildPurpose.wordWrap = true;
            this._txtGuildPurpose.autoSize = TextFieldAutoSize.LEFT;
            this._btnApply = UIFactory.gButton(Language.getString(60074), 110, 250, 64, 24, this);
            return;
        }// end function

        override public function onMouseClick(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            switch(event.target)
            {
                case this._btnApply:
                {
                    _loc_2 = new Object();
                    _loc_2.guildInfo = this._guildData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GUILD_APPLY, _loc_2));
                    hide();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function setGuildInfo(param1:SMiniGuildInfo) : void
        {
            this._guildData = param1;
            this.update();
            return;
        }// end function

        override public function update() : void
        {
            if (!isLoadComplete)
            {
                return;
            }
            if (this._guildData == null)
            {
                return;
            }
            this._txtGuildName.text = this._guildData.guildName;
            this._txtGuildMaster.text = this._guildData.leaderName;
            this._txtGuildLevel.text = this._guildData.level.toString();
            this._txtGuildMembersNum.text = this._guildData.playerNum + "/" + this._guildData.maxPlayerNum;
            var _loc_1:* = GuildNewUtil.getAllBuildByLevel(this._guildData.level);
            var _loc_2:* = int(_loc_1[8].structureLevel);
            this._txtGuildBranchLevel.text = _loc_2 > 0 ? (_loc_2.toString()) : ("" + Language.getString(71183));
            this._txtGuildPurpose.text = this._guildData.purpose;
            return;
        }// end function

        public static function get instance() : GuildIntroducePanel
        {
            if (!_instance)
            {
                _instance = new GuildIntroducePanel;
            }
            return _instance;
        }// end function

    }
}
